Introduction

Stacy DeRuiter
7 August 2017

Why tag?

  • What questions are best answered using tags?
  • What questions are you using tags to answer?

Why tag? A Running Example

DeRuiter et al. 2013

Why tag? A Running Example

  • Study species: Ziphius cavirostris
  • Tag: DTAG3 cuviers

Why tag? A Running Example

Controlled Exposure Experiments (CEEs)

with Mid-frequency Active Sonar (MFAS) CEE

Ethics of tagging

  • Can the question be answered with existing data?
  • Are simulations a viable alternative?
  • Is the tag suitable?
    • sensors, sampling rates
    • accuracy
    • size
    • tagging duration

Ethics in our example

  • Lack of existing data for analysis or simulation
  • Was tag suitable?
    • What sound did whales receive?
    • Do dive behavior, body movement or foraging behavior indicate response?

DTAG3 Sensors (50-200 Hz)

d3 sensors

DTAG3 Sensors (50-200 Hz)

d3 sensors

DTAG3 Sensors (50-200 Hz)

d3 sensors

DTAG3 Sensors (50-200 Hz)

d3 sensors

Ethics of tagging 2

  • Do you need and have a permit?
    • NOAA permits to approach, photograph and tag in SOCAL
  • Do you have IACUC and peer approval?
    • IACUC proposals and many public presentations, consults

Ethics of tagging 3

Ethics of tagging 4

  • How many animals will you need to tag to answer the question? (TWO?)
  • How will you measure responses to tagging (during or after field work)?
  • Can you collect and integrate all of the ancillary data needed?

Ancillary data

  • Visual observations
  • Acoustic tracking
  • Visual and radar tracking of vessels in the area
  • Photos and video
  • Genetics (biopsy, skin sample)
  • Life history of tagged whale (photo-id studies)
  • Oceanographic measurements (CTD, current, bathymetry)

Ancillary data challenges

  • Storage, quality control, archiving (paper? the dreaded spreadsheets?)
  • Accounting for effort
  • Collaboration with others in the study area, data sharing
  • Integrating data with different time scales, varying accuracy

Ethics and Data-Sharing

Types of tag

  • Short-term (day) to Long-term (year)
  • Attachment: suction cups, bolts, straps, glue…
  • Sensors: Geo position, orientation, depth/altitude, sound, video, heart-rate, temperature…
  • Archival vs. Telemetry

Trade-offs, Advantages & Disadvantages

  • Availability of tags & analysis tools
  • “Ease” of attachment (for you and animal)
  • Record duration vs. data density
  • “Ease” of data retrieval

How do you choose a tag type?

  • What question are you trying to answer?
  • Is your tag appropriate?
  • You (may have chosen)…

This workshop: Hi-res movement tags

  • Typically include:
    • Sensors sampled multiple times per second
    • Accelerometers to measure body posture and sudden movements or changes in speed
    • Magnetometers to measure direction of travel
    • Pressure sensors to measure dive depth in aquatic or marine animals

This workshop: Hi-res movement tags

  • May include:
    • Speed sensor
    • Gyroscopes (to measure turning rate)
    • Sound sensors
    • Video recorders

Working with tag data

How do we get from A… tagphoto

… to B? zc-figure

Choose software

  • Matlab
    • Pros: Broad user base, flexible, fast at matrix calculations
    • Cons: Expensive, steep learning curve
  • Octave
    • Pros: Free & open source, “almost matlab” now
    • Cons: Basic user interface, steep learning curve
  • R/RStudio
    • Pros: Free & open source, pro stats standard, tutorials/resources
    • Cons: Slower (?), steep learning curve

Where's the gradual learning curve?

Check out some online learning resources gathered at:

https://github.com/stacyderuiter/TagTools/wiki/Software

Tag tools help & documentation

Learn and contribute at

http://www.animaltags.org animaltags.org

It's a wiki - join us!

Read in data

  • Tag tools can read in:
    • Raw data from several tag types
    • archival format netCDF files (<– our focus)
  • NetCDF files (.nc) must be stored locally before reading.
  • Assume we have a file stored at C:\data\testset1.nc
  • R:
testset1 <- load_nc('C:\data\testset1.nc')
  • Matlab/Octave:
testset1 = load_nc('C:\data\testset1.nc') ;

Calibrate data

Still working on this - will be a VERY brief description of what/why, e.g. raw to scientific units, tag to whale frame. Details left for next lecture.

Attach metadata

Metadata has at least 2 sources:

  • Gleaned automatically from tag data files
  • User-provided

Saving tag metadata to csv (text file)

Still working on this one - will include metadata gleaning example (I hope) plus screen shots of Ye Joo's metadata entry tool.

Archiving data + metadata to netCDF

netCDF format…

  • Developed with NSF funds for geoscience community
  • Is flexible, accomodates data and metadata fields
  • Allows many user-defined fields
  • Supported by well-defined standards and conventions
  • “supports a view of data as a collection of self-describing, portable objects that can be accessed through a simple interface” (-NetCDF website)

Exporting data + metadata to archives

Exporting data + metadata to archives

Tag tool kit installation in R

  • In R, all “tools” must be bundled in packages.
  • To use a package, you must:
    • Install the package (one-time-only)
    • Load the package (every new R session)

Tag tool kit installation in R

Option A) Install “development version” from GitHub

#install.packages('devtools')
devtools::install_github(
  'stacyderuiter/TagTools/R/tagtools')

Tag tool kit installation in R

Option B) Install from your memory stick. In RStudio:

  • Select the Packages tab in the lower right pane
  • Click Install
  • Choose Install from package archive file
  • Click Browse and navigate to the R tagtools zip file on your memory stick
  • Click Install!

(Live Demo)

zip-install

Tag tool kit installation in Matlab

  • Matlab has access to all functions that are:
    • In directories that are on the Matlab Path
    • In the user's current directory (“Current Folder” in GUI)

Tag tool kit installation in Matlab

  • Unpack the Matlab tagtools zip file on your computer
  • In Matlab, in the Home tab, click Set Path
  • Click Add with Subfolders and then select the tagtools directory
  • Click Save to save the modified path

(Live Demo)

mat-path

Tag tool kit installation in Octave

  • Octave has access to all functions that are:
    • In the user's current directory (“File Browser” in GUI)
    • In packages that have been
      • installed (one-time operation) and
      • loaded (every new Octave session)

Tag tool kit installation in Octave

To install the tag tools package (assuming the Matlab/Octave zip file is stored in F:\tagtools\matlab), run:

pkg install tagtools0.0.0.tar.gz

Then to load it:

pkg load tagtools

Dependencies

In Octave, you also need to manually install and load the packages:

  • netcdf
  • signal

If you are online, you can simply run (for example):

pkg install netcdf 
pkg load netcdf

And when it all goes wrong?

For specific tools, help is only a command away. Example: need help with the function plott()?

in Matlab/Octave:

help plott

in R:

?plott
No documentation for 'plott' in specified packages and libraries:
you could try '??plott'

Project directory structure - Best practices

  • As possible, save data, code, and documents in subdirectories of one main project directory
  • Document your work:
    • Save files rather than just running code in the console
    • Document your code with comments and explantions
    • Give variables names that are easy to understand
    • Prefer descriptive labels to numeric identifiers
  • Consider Reproducible Research - code, documentation and report all in one document!

Begin analysis?

(Stay tuned…Maybe after a coffee.)

Exercises to earn your coffee

What is wrong (or right) with this picture? [coming soon]

  • Show screen shots of projects
  • metadata file creation by “Homer”
  • tags on animals (ethics, tag type, benefits…)
  • errors you will see in R/matlab/octave